package com.zxw.common.core.exception;

import com.zxw.common.core.base.res.GobalResponseInterface;

public class AppException extends RuntimeException {

    private static final long serialVersionUID = 821788770285181399L;

    private String msg;

    private String additionalMsg;//追加信息

    private Integer code;


    /**
     * 全局异常通用构造方法
     *
     * @param gobalResponseInterface
     */
    public AppException(GobalResponseInterface gobalResponseInterface) {
        super(gobalResponseInterface.getMsg());
        this.code = gobalResponseInterface.getCode();
        this.msg = gobalResponseInterface.getMsg();
    }

    /**
     * 全局异常追加错误信息构造方法
     *
     * @param gobalResponseInterface
     * @param additionalMsg          追加的信息
     */
    public AppException(GobalResponseInterface gobalResponseInterface, String additionalMsg) {
        super(gobalResponseInterface.getMsg() + additionalMsg);
        this.code = gobalResponseInterface.getCode();
        this.msg = gobalResponseInterface.getMsg();
        this.additionalMsg = additionalMsg;
    }

    public String getMsg() {
        return msg;
    }


    public String getAdditionalMsg() {
        return additionalMsg;
    }


    public Integer getCode() {
        return code;
    }

}
